﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Net.Sockets;
using System.Text;
using System.Threading;
using System.Threading.Tasks;
using System.Xml.Linq;
using Elasticsearch;
using Elasticsearch.Net;

using Nest;
using ES.EsEntity;

namespace ES
{
    internal class Program
    {


        public static void Main(string[] args)
        {
            string result = string.Empty;
            #region
            //ElasticSearchService searchService = new ElasticSearchService();
            ////清除已建索引
            //result = searchService.DeleteIndex();
            //Console.WriteLine(result);

            ////创建索引
            //result = searchService.CreateIndex();
            //Console.WriteLine(result);

            ////添加数据
            //var doctorList = searchService.BuiDoctorEntities();
            //result = searchService.AddDoctorInfoToIndex(doctorList);
            //Console.WriteLine(result);

            //Thread.Sleep(2000); //等待索引数据生成
            ////更新数据
            //var doctors = searchService.QueryDoctors("55882350");
            //doctors.ForEach(o=>o.DoctorName="Zery-Zhang");
            //result = searchService.UpdateDoctorInfoToIndex(doctors);
            //Console.WriteLine(result);
            #endregion

            #region MyRegion
            //删除数据
            //result = searchService.DeleteDoctorInfoToIndex(doctors);
            //Console.WriteLine(result);


            // ElasticBase elasticBase = new ElasticBase();
            //var deleteindex = elasticBase.DeleteIndex();
            //  result = elasticBase.CreateIndex();
            // var listall = elasticBase.GetAll();
            //var deleteindex = elasticBase.Delete(1);
            // var updae = elasticBase.UpdateDocument();
            //var DeleteBulk = elasticBase.DeleteBulk();
            //  var edit = elasticBase.Update();
            //var edit2 = elasticBase.UpdateBulk();
            //var listall1 = elasticBase.GetAll();
            //result = elasticBase.CreateIndex();
            // Console.WriteLine(result);

            //var list=    elasticBase.QueryDoctors("长沙建设创新创业");
            // var list = elasticBase.QueryDoctors("专项"); 
            #endregion

            // ElasticSearchBase.Instance.CreateIndex<PolicyInfo>();

            //PolicyInfo policyInfo = new PolicyInfo();
            //policyInfo.Contents = "erwerwer";
            //policyInfo.id = 444;
            //policyInfo.Desc = "ddd";
            //policyInfo.Title = "sadasdad";

            //var st = ElasticSearchBase.Instance.AddDocument(policyInfo);

            // var list=  ElasticSearchBase.Instance.Query<EsPolicyInfo>("2018年移动互联网怎么搞");
            var list = ElasticSearchBase.Instance.Query<EsPolicyInfo>("长沙移动互联网公司有哪些");

            Console.Read();
        }
    }
}
